home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Internet Surfer: Getting Started
/
Internet Surfer - Getting Started (Wayzata Technology)(7231)(1995).bin
/
pc
/
mac
/
bonus
/
peter_le
/
finger-1
/
my_units
/
myteutil.s
< prev
next >
Wrap
Text File
|
1992-02-24
|
2KB
|
80 lines
unit MyTEUtils;
{ This code is part of the Finger/Fingerd source code, written in THINK Pascal 4 }
{ Copyright 1991-1992 Peter N Lewis }
{ If you use this code, you must give me credit in your about box and documentation }
{ This is part of my generic library of routines }
interface
function TEEditMenuEnabled (te: TEHandle; static: boolean; maxsize: longInt): boolean;
procedure TESetEditMenuItem (te: TEHandle; static: boolean; maxsize: longInt; item: integer);
function TEDoEditMenu (te: TEHandle; static: boolean; maxsize: longInt; item: integer): boolean;
implementation
uses
MyTypes, BaseGlobals, MyUtils;
function TEEditMenuEnabled (te: TEHandle; static: boolean; maxsize: longInt): boolean;
var
i: integer;
begin
for i := EMundo to EMselectall do
TESetEditMenuItem(te, static, maxsize, i);
TEEditMenuEnabled := GetMHandle(M_Edit)^^.enableFlags <> 0;
end;
procedure TESetEditMenuItem (te: TEHandle; static: boolean; maxsize: longInt; item: integer);
var
offset: longInt;
begin
case item of
EMundo:
SetIDItemEnable(M_Edit, item, false);
EMcut, EMclear:
SetIDItemEnable(M_Edit, item, not static & (te^^.selStart < te^^.selEnd)); { Can cut,clear if there is a selection }
EMcopy:
SetIDItemEnable(M_Edit, item, te^^.selStart < te^^.selEnd); { Can copy iff there is a selection }
EMpaste:
SetIDItemEnable(M_Edit, item, not static & (GetScrap(nil, 'TEXT', offset) > 0) & (TEGetScrapLen + (te^^.teLength - (te^^.selEnd - te^^.selStart)) < maxsize));
EMselectall:
SetIDItemEnable(M_Edit, item, te^^.teLength > 0); { Can select all iff there is something to select }
otherwise
end;
end;
function TEDoEditMenu (te: TEHandle; static: boolean; maxsize: longInt; item: integer): boolean;
var
loe, oe: OSErr;
begin
TEDoEditMenu := true;
case item of
EMcopy: begin
TECopy(te);
loe := ZeroScrap;
oe := TEToScrap;
TEDoEditMenu := false;
end;
EMselectall: begin
SetPort(FrontWindow);
TESetSelect(0, maxLongInt, te);
TEDoEditMenu := false;
end;
EMcut: begin
TECut(te);
loe := ZeroScrap;
oe := TEToScrap;
end;
EMclear: begin
TEDelete(te);
end;
EMpaste: begin
oe := TEFromScrap;
TEPaste(te);
end;
otherwise
end;
end;
end.